package com.jxd.hbase.analysis;

import com.jxd.config.HbaseConfig;
import com.jxd.entity.MesContent;
import com.jxd.entity.MesHead;
import com.jxd.hbase.utils.QurryTableUntil;
import com.jxd.model.FaultType;
import com.jxd.repositories.MesHeadRepositories;
import com.jxd.service.FaultTypeService;
import org.apache.hadoop.hbase.client.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Service
public class FaultStatistics {
    @Value("${hbase.bwcontent.tablename}")
    private String bwContentTableName;
    @Autowired
    private FaultTypeService faultTypeService;
    @Autowired
    @Qualifier("getHtableByMesContent")
    HTable mesContentClient;
    @Autowired
    MesHeadRepositories mesHeadRepositories;

    public void getFaultStatistics(String shipid, String filename, String mesid ,Connection connection ){
        /**
         * mesid1 61632 F
         * mesid2 53296 D
         * mesid3 57392 E
         *  mesid4 49376 C
         *  获取所有的故障报文
         */
        String tableName = bwContentTableName;
        long st = new Date().getTime();
        List<MesHead> mesHeadList = faultTypeService.getFeedbackMess(filename, shipid, mesid);
        List<FaultType> faultTypes = faultTypeService.getFaultTypes(mesHeadList, tableName, connection);
        faultTypeService.insertFaultType(faultTypes, shipid, "222", "22");
        long inserttime = new Date().getTime();
        System.out.println("线程号"+mesid+"总时间======="+(inserttime-st));

    }

}

